/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : SightWordAction.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Dec 12, 2008       Raghu Sarraff			       Created
 */
package lwf.web.struts.action.english;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import lwf.handler.IProcessHandler;
import lwf.handler.english.SightWordHandler;
import lwf.handler.english.WordHandler;
import lwf.handler.entities.english.word.WordType;
import lwf.web.struts.action.form.english.WordDisplayActionForm;

import net.lwf.common.constant.ICommonConstant;
import net.lwf.entity.UserPreferences;
import net.lwf.web.constant.IPageTitle;
import net.lwf.web.constant.IWebConstant;

import org.apache.struts.action.ActionForm;


/**
 * Type the class description here
 *  
 */
public class SightWordAction extends WordAction {
	
	/**
	 * @see net.lwf.web.struts.action.english.WordAction#getHandler(HttpServletRequest)
	 */
	public WordHandler getHandler(HttpServletRequest request, ActionForm form) {
        int start = getStart(request);
        int end = getEnd(request);
        
        WordDisplayActionForm wdaf = (WordDisplayActionForm) form;
		SightWordHandler handler = null;
		if(start == 0 && end == 0) {
			//return new SightWordHandler();
		}
		if(wdaf.getGradeLevel() != 0) {
			return new SightWordHandler(start, end, wdaf.getGradeLevel());
		}
		return new SightWordHandler(start, end);
	}
	
//	public void checkGrade(HttpServletRequest request, ActionForm form) {
//		WordDisplayActionForm wdaf = (WordDisplayActionForm) form;
//		UserPreferences preferences = (UserPreferences) request.getSession().getAttribute(IOperation.PREFERENCES);
//		if(!preferences.getLevel().equals(IOperation.PRE_SCHOOL)) {
//			wdaf.setDisplayLevel(true);
//		}
//		else {
//			wdaf.setDisplayLevel(false);
//		}
//	}	
	
	public void checkGrade(HttpServletRequest request, ActionForm form) {
		WordDisplayActionForm wdaf = (WordDisplayActionForm) form;
		UserPreferences preferences = getWebUser(request).getPreferences();
		List lstLevels = new ArrayList();
		lstLevels.add(new WordType(ICommonConstant.VERY_SIMPLE, "Very Simple"));
		lstLevels.add(new WordType(ICommonConstant.SIMPLE, "Simple"));
		if(!preferences.getLevel().equals(IWebConstant.PRE_SCHOOL)) {
			lstLevels.add(new WordType(ICommonConstant.MEDUIM, "Medium"));
			lstLevels.add(new WordType(ICommonConstant.ABOVE_MEDIUM, "Above Medium"));
			lstLevels.add(new WordType(ICommonConstant.HARD, "Hard"));
		}
		wdaf.setLevels(lstLevels);
	}	
	
	public int getDisplayRows(ActionForm form) {
		WordDisplayActionForm wdaf = (WordDisplayActionForm) form;
		return wdaf.getDisprows();
	}

	@Override
	public IProcessHandler getHandler(HttpServletRequest request) {
		return null;
	}

	@Override
	public String getPageTitle() {
		return IPageTitle.SIGHT_WORDS;
	}

	@Override
	public String getMainTitle() {
		return null;
	}

	@Override
	public String getPdfLink() {
		return null;
	}

	@Override
	public String getQuizLink() {
		return null;
	}
	
} //SightWordAction

